//
//  HYActivity.m
//  XPlayer
//
//  Created by 张水 on 2023/9/26.
//

#import "HYActivity.h"

@implementation HYActivity
- (instancetype)initWithTitle:(NSString *)title withActivityImage:(UIImage *)image withUrl:(NSURL *)url  withShareContext:(NSArray *)shareContexts
{
    if(self == [super init]){
        _title = title;
        _image = image;
        _url = url;
        _shareContexts = shareContexts;
    }
    return self;
    
}
//显示的位置最上面带AirDrop的
+ (UIActivityCategory)activityCategory
{
    return UIActivityCategoryAction;
}

- (NSString *)activityTitle
{
    return _title;
}
- (UIImage *)_activityImage
{
    return _image;
}

- (NSURL *)activityUrl
{
    return _url;
}

- (BOOL)canPerformWithActivityItems:(NSArray *)activityItems {
    if (activityItems.count > 0) {
        return YES;
    }
    return NO;
}

- (void)performActivity {
    [[UIApplication sharedApplication] openURL:self.activityUrl];
    [self activityDidFinish:YES];
}
@end
